﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FlightSystemDBLayer
{
  class SQLAccess
{
      
   ////private static final String  driver = "jdbc:sqlserver://localhost:1433";
   // private static final String  databaseName = ";databaseName=company";
//jdbc:sqlserver://localhost\SQLEXPRESS/Databases/EPS:1357;user=epsingall;password=welkom1;
        public static readonly string connectionString = @"Data Source=balder.ucn.dk; Initial Catalog=dmaai0913Group6; User ID=dmaai0913Group6; Password=IsAllowed;";
        public static readonly SqlConnection dbconn = new SqlConnection(connectionString);

        //private static SqlCommand dbCmd;

        //this one I don't like it, now here's is why, 1st we can make new connection 
      //each time we use code and kill it afterwards, or we need make singleton, how ever 
      //keeping connection active for prolonged time is bad, 2nd probably there is a way to reduce code by using common connection
      //sqlCommand and maybe even DataSet for this I need some testing and playing around now we don't have time so I leave this comment for my self

        //public static void Open()
        //{
        //    if (dbconn.State.ToString().CompareTo("Open") != 0)
        //    {
        //        dbconn.Open();
              
        //    }
        //}

        //public static void Close()
        //{
        //    dbconn.Close();
        //}

        //public static SqlCommand GetDbCommand(string sql)
        //{
        //    if (dbconn.State.ToString().CompareTo("Open") != 0)
        //        Open();
        //    if (dbCmd == null)
        //    {
        //        dbCmd = new SqlCommand(sql, dbconn);
        //    }
        //    dbCmd.CommandText = sql;
        //    return dbCmd;
        //}
    }
}

